OXY-143: Add ConfigFileService for runtime config-file management - #295
Open
Kalin-Rudnicki wants to merge 2 commits into
Open
OXY-143: Add ConfigFileService for runtime config-file management#295Kalin-Rudnicki wants to merge 2 commits into
Kalin-Rudnicki wants to merge 2 commits into
Conversation
Introduce a reusable, injectable ZIO service (`ConfigFileService`) that centralizes
the config-file lifecycle: load / merge / list / exists / atomic save for JSON + YAML
files, with a typed `ConfigFileError` ADT.
Refactor the private `ConfigLoader` (backing `@envConfig`) to delegate to
`ConfigFileService.Live.loadResolved`, so the startup and runtime paths share a single
implementation (same file/dir resolution, JSON/YAML handling, and directory-merge order).
- New `oxygen.executable.config.{ConfigFileService, ConfigFileError}` with live/default/test layers.
- Atomic save via temp-sibling + move; parent dirs auto-created.
- Directory merge sorts by path then reduceLeft(_ ++ _) (deterministic precedence).
- 14 unit tests (round-trip, directory-merge, missing-path, errors); JVM/JS/Native compile.
- Docs: executable/config-files.md contrasting @envconfig (startup) vs the service (runtime).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
🤖 Automated multi-agent review (confirmed findings)Highsave() cannot overwrite an existing config file — moveTo has no REPLACE_EXISTING These are AI-generated, adversarially-verified findings and may still contain false positives. |
save() moved a temp sibling into place via JavaPath.moveTo, which called Files.move without REPLACE_EXISTING and therefore threw FileAlreadyExistsException when the destination already existed (the service's core update-an-existing-config case). Add an overwrite-capable moveTo(dest, replaceExisting) overload (default false preserves existing callers) and use replaceExisting = true in save(). Add a unit test proving save() overwrites an existing file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011YxWKdsz97QT9BD7AdpSq6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OXY-143 — Create a service for managing config files
Adds a reusable, injectable ZIO service that centralizes the config-file lifecycle, and unifies it with the existing
@envConfigstartup path.What was done
ConfigFileService(oxygen.executable.config) — trait +live/default/testZLayers + accessors +Live:load[A]/loadJson,save[A](atomic: serialize-by-extension → temp sibling →moveTo, auto-creates parent dirs)mergeDirectory[A]/mergeDirectoryJson(reduceLeft(_ ++ _), sorted by path for deterministic precedence)loadResolved[A](file→load, dir→merge — the@envConfigsemantics),list,existsConfigFileErrortyped ADT (wrapsFileSystemError+ JSON/YAML decode failures; mirrorsTestContainerError/MigrationError)..json/.yaml/.yml) viaoxygen-json/YamlParser/YamlWriter; respectsFileSystem.current.ConfigLoader(@envConfig) to delegate toConfigFileService.Live.loadResolved, so startup and runtime cannot diverge.docs/docs/executable/config-files.mdcontrasting@envConfig(startup) vs the service (runtime); added to nav.Placement decision
Lives in
oxygen-executable(the ticket's documented alternative), notoxygen-zio: the service needsYamlParser, andoxygen-ziodoes not depend onoxygen-yaml.oxygen-executablealready depends on both and ownsConfigLoader.Verification
oxygen-executableJVM/test: 43 passed / 0 failed (14 new + existing@envConfigtests).oxygen-executableJS/compile+oxygen-executableNative/compile: success.Notes
report/OXY-143.md.🤖 Generated with Claude Code